Common CloudFoundry CF CLI Commands

Getting Started with the CF CLI

If you haven't installed the CF CLI tools please start here

Admin Keys (CS-Devops Only):

https://github.sw.ge.com/industrial-cloud/ice-deploy-keys/blob/master/CF_login_deets.md

Cloud Foundry Deployments

Environment API Endpoint PRE-PROD (R2) api.grc-apps.svc.ice.ge.com PRODUCTION (R4) api.grc-pr-apps.ice.ge.com ILYA (R3) api.grc2-apps.svc.ice.ge.com Cloud Foundry CF CLI commands

Login to a Cloud Foundry Deployment:

cf login -a https://api.grc-apps.svc.ice.ge.com Enter your username (GE Email address or admin) and password when prompted.

To see all orgs:

$ cf orgs Getting orgs as admin...

name test CATS-persistent-org system-broker predix-apm csops system predix-acs predix-asset predix-docs predix-experience predix-timeseries To see all spaces in an org, target the org, then list spaces: $ cf target -o predix-acs

API endpoint: https://api.grc-pr-apps.ice.ge.com (API version: 2.18.0) User: admin Org: predix-acs Space: No space targeted, use 'cf target -s SPACE'

$ cf spaces Getting spaces in org predix-acs as admin...

name prod To see all apps in an org / space, target the space, list apps: $ cf target -o predix-acs -s prod

API endpoint: https://api.grc-pr-apps.ice.ge.com (API version: 2.18.0) User: admin Org: predix-acs Space: prod

$ cf apps Getting apps in org predix-acs / space prod as admin... OK

name requested state instances memory disk urls acs-29 started 2/2 1G 1G acs.grc-pr-apps.ice.ge.com, acs-29.grc-pr-apps.ice.ge.com predix-acs-kibana started 1/1 128M 1G predix-acs-kibana.grc-pr-apps.ice.ge.com predix-acs-sb started 1/1 1G 1G predix-acs-sb.grc-pr-apps.ice.ge.com PRO-TIP:

URLS indicate the 'routes' or 'endpoints' the application is listening on. The App Name will have a number at the end, this number is the Jenkins Build number used to deploy the application To show basic health and status of an app: $ cf app acs-29 Showing health and status for app acs-29 in org predix-acs / space prod as admin... OK

requested state: started instances: 2/2 usage: 1G x 2 instances urls: acs.grc-pr-apps.ice.ge.com, acs-29.grc-pr-apps.ice.ge.com last uploaded: Wed Mar 25 17:52:03 +0000 2015

   state     since                    cpu    memory         disk           details

0 running 2015-03-26 08:17:07 PM 0.1% 749.7M of 1G 164.1M of 1G

1 running 2015-03-26 08:17:10 PM 0.0% 697.2M of 1G 164.1M of 1G

PRO-TIP:

You can see how long the service has been running (good for crash detection) To show real-time log output from an app: cf logs acs-29 Connected, tailing logs for app acs-29 in org predix-acs / space prod as admin...

2015-03-27T17:17:35.05-0700 [App/0] OUT 2015-03-28 00:17:35 DEBUG [http-nio-61020-exec-8] com.ge.predix.acs.service.policy.evaluation.PolicyEvaluationServiceImpl [PolicyEvaluationServiceImpl.java:75] Policy Evaluation in the context of: issuer=[https://uaa-portal.nurego.com/oauth/token], client=[apm_app], resourceUri=[/services/apm/assetregistry/site/EBECE516EDE042FEAA4C52E4A3C6B648], subjectId=[502401855], action=[GET], number of policy sets found=[1] 2015-03-27T17:17:35.06-0700 [App/0] OUT 2015-03-28 00:17:35 DEBUG [http-nio-61020-exec-8] com.ge.predix.acs.privilege.management.PrivilegeManagementServiceImpl [PrivilegeManagementServiceImpl.java:250] Unable to find the subject for subjectId=502401855, issuerId =https://uaa-portal.nurego.com/oauth/token and clientId=apm_app 2015-03-27T17:17:35.06-0700 [App/0] OUT 2015-03-28 00:17:35 DEBUG [http-nio-61020-exec-8] com.ge.predix.acs.privilege.management.PrivilegeManagementServiceImpl [PrivilegeManagementServiceImpl.java:121] Unable to find the resource for resourceIdentifier=/services/apm/assetregistry/site/EBECE516EDE042FEAA4C52E4A3C6B648 , issuerId=https://uaa-portal.nurego.com/oauth/token and clientId=apm_app 2015-03-27T17:17:35.06-0700 [App/0] OUT 2015-03-28 00:17:35 DEBUG [http-nio-61020-exec-8] com.ge.predix.acs.service.policy.evaluation.PolicyEvaluationServiceImpl [PolicyEvaluationServiceImpl.java:264] Subject Attributes : To show 'recent' app logs:

$ cf logs acs-29 --recent 2015-03-27T17:17:37.26-0700 [App/1] OUT 2015-03-28 00:17:37 INFO [http-nio-61035-exec-5] com.ge.predix.acs.service.policy.evaluation.PolicyEvaluationServiceImpl [PolicyEvaluationServiceImpl.java:136] Policy Evaluation decision : policy set name=[PolicySet-for-APM], policy name=[Allow all operations by default], effect=[PERMIT] 2015-03-27T17:17:44.91-0700 [RTR/0] OUT acs.grc-pr-apps.ice.ge.com - [28/03/2015:00:17:44 +0000] "POST /policy-evaluation HTTP/1.1" 200 66 "-" "Java/1.8.0_40-" 10.202.76.16:52675 x_forwarded_for:"10.202.76.53" vcap_request_id:976679c1-b587-4c05-5377-d08ba896b8bb response_time:0.033419131 app_id:d286ba8a-d1ab-445a-a364-1a8cb589d5dc 2015-03-27T17:17:49.53-0700 [RTR/0] OUT acs.grc-pr-apps.ice.ge.com - [28/03/2015:00:17:49 +0000] "POST /policy-evaluation HTTP/1.1" 200 66 "-" "Java/1.8.0_40-" 10.202.76.16:52719 x_forwarded_for:"10.202.76.53" vcap_request_id:2a7edce2-2099-4613-787e-147312c917b8 response_time:0.182726153 app_id:d286ba8a-d1ab-445a-a364-1a8cb589d5dc 2015-03-27T17:18:02.30-0700 [RTR/0] OUT acs.grc-pr-apps.ice.ge.com - [28/03/2015:00:18:02 +0000] "POST /policy-evaluation HTTP/1.1" 200 66 "-" "Java/1.8.0_40-" 10.202.76.16:57700 x_forwarded_for:"10.202.76.53" vcap_request_id:5c95475d-5c85-495d-6747-939250d6fb3a response_time:0.030911640 app_id:d286ba8a-d1ab-445a-a364-1a8cb589d5dc PRO-TIP:

This will show the most recent logs in buffer... Your milage may vary. To see all services and service binding in an org / space:

$ cf services Getting services in org predix-acs / space prod as admin... OK

name service plan bound apps last operation acs_db p-mysql 500mb-dev acs-29 succeeded logstash-acs-service logstash14 free acs-29, predix-acs-kibana succeeded mysql-acs-sb p-mysql 500mb-dev predix-acs-sb succeeded To show a list of services available for use in an org: $ cf marketplace Getting services from marketplace in org predix-acs / space prod as admin... OK

service plans description logstash14 free Logstash 1.4 service for application development and testing newrelic-gea standard Manage and monitor GE Aviation apps newrelic-gec standard Manage and monitor GE Capital application newrelic-geem standard Manage and monitor GE Energy apps newrelic-gehc standard Manage and monitor GE Healthcare apps newrelic-geog standard Manage and monitor GE Oil and Gas apps newrelic-gepw standard Manage and monitor GE Power and Water apps newrelic-getr standard Manage and monitor GE Transportation apps newrelic-grc standard Manage and monitor GE Global Research apps newrelic-predix standard Manage and monitor Predix platform newrelic-prod standard Manage and monitor GE Production apps p-mysql 100mb-dev, 1gb-dev, 500mb-dev, 10gb-prod A MySQL service for application development and testing p-rabbitmq standard RabbitMQ is a robust and scalable high-performance multi-protocol messaging broker. p-redis shared-vm, dedicated-vm Redis service to provide a key-value store p-riakcs developer An S3-compatible object store based on Riak CS predix-acs Basic-Free Fine Grained Access Control Service predix-asset Basic Service to model and manages industrial assets predix-time-series basic-free Predix Time Series Service predix-views basic Predix view service

  • These service plans have an associated cost. Creating a service instance will incur this cost. PRO-TIP

Use 'cf marketplace -s SERVICE' to view descriptions of individual plans of a given service. To quickly show active routes: $ cf routes Getting routes as admin ...

host domain apps acs-19-staging grc-pr-apps.ice.ge.com acs grc-pr-apps.ice.ge.com acs-29 acs- grc-pr-apps.ice.ge.com predix-acs-sb grc-pr-apps.ice.ge.com predix-acs-sb acs-7 grc-pr-apps.ice.ge.com acs-24 grc-pr-apps.ice.ge.com acs-29 grc-pr-apps.ice.ge.com acs-29 kibana-ui-doctrinal-finagler grc-pr-apps.ice.ge.com kibana-ui grc-pr-apps.ice.ge.com predix-acs-kibana grc-pr-apps.ice.ge.com predix-acs-kibana PRO-TIP

Active routes have an app name associated with them. In the above output there are 4 active routs and 6 inactive routes Inactive routes can cause conflicts when trying to deploy a new app with the same name